package list_;

import java.util.*;

/**
 * @author DCSGO
 * @version 1.0
 * List的三个实现子类
 * ArrayList LinkedList
 * Vector 的三种遍历方式
 */
public class ListFor {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        //只需将 new 的对象替换成对应的 List 子类即可
        //List list = new ArrayList();
        //List list = new LinkedList();
        List list = new Vector();

        list.add("CS1.6");
        list.add("CSS");
        list.add("CSGO");
        list.add("CS2");

        //1.迭代器
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object o = iterator.next();
            System.out.print(o + " ");
        }//CS1.6 CSS CSGO CS2

        System.out.println();
        //2.foreach
        for (Object o : list) {
            System.out.print(o + " ");
        }//CS1.6 CSS CSGO CS2

        System.out.println();
        //3.普通for循环
        for (int i = 0; i < list.size(); i++) {
            Object o = list.get(i);
            System.out.print(o + " ");
        }//CS1.6 CSS CSGO CS2
    }
}
